#pragma once
#include<iostream>
#include<sys/types.h>
#include<unistd.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<sys/socket.h>
#include<string>
class InetAddr
{
    public:
    InetAddr(struct sockaddr_in addr):_addr(addr)
    {
        _ip=inet_ntoa(_addr.sin_addr);
        _port=ntohs(_addr.sin_port);
    }
    std::string Ip()
    {
        return _ip;
    }
    uint16_t Port()
    {
        return _port;
    }
    bool operator ==(const InetAddr& peer)
    {
        if(peer._ip==_ip&&peer._port==_port)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    std::string StringAddr()
    {
        return _ip+":"+std::to_string(_port)+"# ";
    }
    struct sockaddr_in& Netaddr()
    {
        return _addr;
    }
    private:
    std::string _ip;
    uint16_t _port;
    struct sockaddr_in _addr;
};

